<template>
  <div id='tmpl'>
       <div class="title">
            <h3 v-text='info.title'></h3>
            <p>{{ info.add_time | datefmt('YYYY-MM-DD')}} {{info.click}}浏览</p>
       </div>
       <div class="detail" v-html='info.content'></div>
        //使用评论组件
       <comment :id="newsId"></comment>
  </div>
</template>
<script>
import {Toast} from 'mint-ui';
//导入评论组件
import comment from '../subnews/newsComment.vue'

export default {
  components:{
      comment //引入评论组件
  },
  data () {
    return {
        newsId:0,
        info:{
          //假数据格式
              // status: 0,
              // message: [
              //           {
              //             id: 13,
              //             title: "1季度多家房企利润跌幅超50% 去库存促销战打响",
              //             click: 1,
              //             add_time: "2015-04-16T03:50:28.000Z",
              //             content:
              //       }
              // ]
        }
    };
  },
  created(){
      this.newsId=this.$route.params.id,
      this.getinfo();
  },
  methods:{
    getinfo(){
      var url = this.$common.apidomain + '/api/getnew/' + this.newsId;
      this.$http.get(url).then(function(res){
          var data = res.body;
          if(data.status !=0){
              Toast('详情页面不存在');
              return;
          }
          this.info = data.message[0];
      });
    }
  }
  
}
</script>
<style lang="css" scoped>
        .title{
          text-align: center;
          color: deepskyblue;
          border-bottom: 1px solid gray;
        }
        .title p {
          color:red;
        }
        .detail{
          padding:10px;
          text-indent: 2em;
        }
</style>